<?php
// https://leetcode-cn.com/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof/
class Solution {

    /**
     * @param Integer[] $nums
     * @return Integer
     */
    function findRepeatNumber($nums) {
        $index = 0;
        while ($index < count($nums)) {
            if ($nums[$index] == $index) {
                $index++;
                continue;
            }
            if ($nums[$index] == $nums[$nums[$index]]) {
                return $nums[$index];
            }
            [$nums[$nums[$index]], $nums[$index]] = [$nums[$index], $nums[$nums[$index]]];
        }

        return -1;
    }
}

$arr = [2, 3, 1, 0, 2, 5, 3];
$soulution = new Solution();
$result = $soulution->findRepeatNumber($arr);
var_dump($result);